using UnityEngine;

[ExecuteInEditMode]
[AddComponentMenu("Image Effects/Desaturate")]
public class DesaturateEffect : ImageEffectBase {
	public float desaturateAmount = 0.2f;
	public Texture textureRamp;
	public float rampOffsetR = -0.07f;
	public float rampOffsetG = -0.01f;
	public float rampOffsetB = -0.01f;

	// Called by camera to apply image effect
	void OnRenderImage (RenderTexture source, RenderTexture destination) {
		material.SetTexture("_RampTex", textureRamp);
		material.SetFloat("_Desat", desaturateAmount);
		material.SetVector("_RampOffset", new Vector4 (rampOffsetR, rampOffsetG, rampOffsetB, 0));
		Graphics.Blit(source,destination,material);
	}
}